LESSON 6
CUSTOM FLOP PATTERN
Version 6.0

This lesson is a continuation of the LESSON 5 example program, providing the option to flop write a pattern. Flopping a pattern requires a specific subroutine to direct the magic hardware. Like the normal write presented in LESSON 5, a flop write can also be written using one of the 3 magic functions plop,XOR,OR however, bit 6 in the Magic Register must be set to tell the magic hardware that a magic flop is being requested.

This particular pattern flop write subroutine is a near copy of the magic pattern flop write labeled WRFL1, which is located in the Bally/Astrocade ROM. See the NM ROM code listing on pages 50 and 51, address 0751H (cross stmt 2279).

EXAMPLE 6-1

Program Description

Use the entire Example Program 5-1 in LESSON 5.
Include with this program, the option to flop the plane pattern.
Add the following Z80 coding listed below to the entered Example Program 5-1.
Follow the program instructions below to write (display) the normal plane pattern or to flop the plane pattern.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Example Program 6-1

Enter the Example Program 5-1 as listed in LESSON 5.
If you STILL have this program in memory, use the MLM LIST command to check/restore the program so it matches the original listing.

Run this Example Program 5-1 to confirm it executes correctly.

Add the following Z80 coding to the original Example Program 5-1 you now have entered into memory.

	4E48H	CB 77		BIT 6,A	[flop bit set?
	4E4AH	20 04		JR NZ,PGM3	 if so, jmp to flop write the plane]

	CODING FROM EXAMPLE PROGRAM 5-1 (NO CHANGE)

	4E4CH	CD 22 4E
	4E4FH	C9

	ENTER NEW CODING AT ADDRESS 4E50H

PGM3	4E50H 13		INC DE	[point DE at initial magic address
		13		INC DE	 which is 0066H for a flop]
		CD 56 4E	CALL WFPAT	flop write the plane
PGM4	4E55H C9		RET		return to MLM

	FLOP THE PATTERN
	ENTER WITH:
	HL = PATTERN ADDRESS
	 B = Y PATTERN SIZE (LINES HIGH)
	 C = X PATTERN SIZE (BYTES WIDE)
	DE = INITIAL MAGIC ADDRESS FOR PATTERN FLOP WRITE
	     (upper right initial magic address for flopped write)

WFPAT	4E56H	AF		XOR A		Zero A
FPAT1		C5		PUSH BC	save YSIZE, XSIZE
		D5		PUSH DE	save magic adr (1st address in line)
		47		LD B,A	B = 0
FPAT2	4E5AH	ED A0		LDI		write a byte
						(DE)<--(HL)
						INC DE
						INC HL
						DEC BC
		1B		DEC DE	[backup magic address
		1B		DEC DE	 for next flopped write]
		EA 5A 4E	JP PE,FPAT2	BC = 0? finished writing the line?
						If not, loop back to write next byte on 							line
	4E61H	12		LD (DE),A	clear final byte for any final shift
		D1		POP DE	get initial line magic address
		EB		EX DE,HL	put that address in HL
		0E 28		LD C,28H	C = bytes per line = 40, B=0
		09		ADD HL,BC	point HL at magic adr of next line
		EB		EX DE,HL	DE = magic adr of next line
						HL = pattern adr of next line
		C1		POP BC	put YSIZE, XSIZE back in BC
		10 EC		DJNZ FPAT1	loop back 20 bytes to write next line
						 20 = 0001 0100
						cpl = 1110 1011
						 +1 = _______+1
						      1110 1100
							  E    C
						jump back code = ECH
	4E6BH	C9		RET		finished flop pattern write
						return to PGM4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Program Execution Instructions

To write the normal plane pattern, enter the byte 00H at 4E3CH and call 4E10H.
	4E3BH	3E 00		LD A,MREG	A = magic register request
				                zero shift, plop write

To write the flopped plane pattern, enter the byte 0100 0000 = 40H at 4E3CH and call 4E10H.
	4E3BH	3E 40		LD A,MREG	A = magic register request
						    zero shift, flop pattern (bit 6 = 1),
						    plop write

Beginner Exercises

1. Try flopping and shifting 1,2 or 3 pixels left by entering at 4E3CH 41,42 and 43H respectively.

2. You can also flop, shift and write with XOR or OR logical by setting up the appropriate bits 5 and 4. See LESSON 5, page 1, for plop,XOR,OR table. Try running some experiments similar to the Beginner Exercises 2, 3 and 4 in  LESSON 5. Use the programming at PGM3, address 4E50H as an adjustment guide when writing normal and flopped patterns to other magic addresses like 0000H or 0025H so the normal and flopped writes occur at the same area in screen RAM. The flop adjustment in this program is an increment of 2 to the normal write  initial magic address because the pattern in this program is 3 bytes wide.

End of LESSON 6 document
Custom Flop Pattern
MCM Design
AUG 2019